import Vue from "vue";
import Vuex from "vuex";
import {db} from "../common/cloudbase";
Vue.use(Vuex);

export default new Vuex.Store({
  state: {

    // 用户数据
    user: null,
    // 用户是否初始化检查
    userChecked: false,
    // 获取文件夹信息
    foldersData: []
  },
  mutations: {
    /**
     * 设置用户数据
     * @param state
     * @param user
     */
    setUserData(state,user){
      console.log(user);
      state.user = user;
    },
    setUserChecked(state,checked){
      state.userChecked = checked;
    },
    setFoldersData(state,data){
      state.foldersData = data;
    }
  },
  actions: {
    async getFolderData({commit}){
      let res = await db.collection("folders").get();
      commit('setFoldersData',res.data);
    }

  },
  modules: {
  },
});
